﻿namespace Ruirun.Mes.EntityConfiguration
{
    /// <summary>
    /// 文件内容实体映射配置
    /// </summary>
    public class WareHouseAreaPosConfiguration : EntityTypeConfigurationBase<WareHouseAreaPos, Guid>
    {
        /// <summary>
        /// 获取 所属的数据上下文类型
        /// </summary>
        public override Type DbContextType => typeof(MesDbContext);

        /// <summary>
        /// 重写以实现实体类型各个属性的数据库配置
        /// </summary>
        /// <param name="builder">实体类型创建器</param>
        public override void Configuration(EntityTypeBuilder<WareHouseAreaPos> builder)
        {
            builder.HasIndex(m => new { m.WareHouseAreaId, m.AreaPosName }).SetIndex("WareHouseAreaPosName", true);

            builder.HasOne(e => e.WareHouseArea).WithMany(d => d.WareHouseAreaPoses)
                .HasForeignKey(da => da.WareHouseAreaId).SetForeignKey("WareHouseAreaId", true);
        }
    }
}
